package cn.kingfeng.util.database;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class DataBase {
	Connection con = null;

	Statement stmt = null;

	ResultSet rs = null;

	public ResultSet sqlResultSet(String sql) {
		try {
			con = DataSrc.getConnection();
			stmt = con.createStatement();
			rs = stmt.executeQuery(sql);
			return rs;
		} catch (Exception e) {
			return null;
		}
	}

	public boolean sqlUpdate(String sql) {
		try {
			con = DataSrc.getConnection();
			stmt = con.createStatement();
			int i = stmt.executeUpdate(sql);
			if (i == 0)
				return false;
			else
				return true;
		} catch (Exception e) {
			return false;
		}
	}

	public void close() throws Exception {
		try {
			if (rs != null)
				rs.close();
		} catch (Exception e) {
		}
		if (stmt != null)
			stmt.close();
		if (con != null)
			DataSrc.close(con);
	}
}